<% @main_header = "#{link_to('Ptrack:', '/')} #{@project.name if @project}: Contacts" %>

<div style="color:red;">
<%= error_messages_for :contact %>
</div>

<% form_for :contact, @contact, :url => {:action => 'update', :id => @contact}, :html => {:method => :put} do |f| %>
<div style="float: left; width: 100%;">
<fieldset>
<legend>Contact Information</legend>
<table>
	<tr>
		<td>
			<%= f.label :name, 'Name:'%>
		</td>
		<td>
			<%= f.text_field :name, :tabindex => "1"  %>
		</td>
		<td>
			<%= f.label :company, 'Company:' %>
		</td>
		<td>
			<% if @contact.inhouse %>
				<%= f.text_field :company, :disabled => true %>
			<%else%>
				<%= f.text_field :company, {:disabled => false, :tabindex => "7"} %>
			<%end%>	
		</td>
	</tr>
	<tr>
		<td>
			<%= f.label :surname, 'Surname:' %>
		</td>
		<td>
			<%= f.text_field :surname , :tabindex => "2" %>
		</td>
		<td>
			<%= f.label :profession, 'Profession:' %>
		</td>
		<td>
			<%= f.text_field :profession, :tabindex => "8" %>
		</td>
		
	</tr>
	<tr>
		<td>
			<%= f.label :phone, 'Phone Number:' %>
		</td>
		<td>
			<%= f.text_field :phone, :tabindex => "3" %>
		</td>
		<td>
			<%= f.label :inhouse, 'Inhouse Personnel:' %>
		</td>
		<td>
			<%= f.check_box :inhouse, {:onchange => "javascript:inhousetoggle()", :tabindex => "9"}%>
		</td>
	</tr>
	<tr>
		<td>
			<%= f.label :fax, 'Fax Number:' %>
		</td>
		<td>
			<%= f.text_field :fax, :tabindex => "4" %>
		</td>
		<td>
			<%= f.label :email, 'E-mail Address:' %>
		</td>
		<td>
			<%= f.text_field :email, :tabindex => "10" %>			
		</td>
	</tr>
	<tr>
		<td>
			<%= f.label :mobile, 'Mobile Phone Number:' %>
		</td>
		<td>
			<%= f.text_field :mobile, :tabindex => "5" %>
		</td>
		<td></td>
		<td></td>
	</tr>
	<tr>
		<td style="vertical-align:top;">
			<%= f.label :address, 'Address:' %>
		</td>
		<td>
			<%= f.text_area :address, {:tabindex => "6", :style => "width:193px; height:80px;" } %>
		</td>
		<td></td>
		<td></td>
	</tr>
</table>
</fieldset>
</div>


<br/>

<table style="width: 100%;">
	<tr>
		<td style="text-align: right; width: 50%;">
			<%= f.submit "Update Contact" %> 
		</td>
	
<% end %>
		<td style="text-align: left; width: 50%;">
			<%= button_to "Cancel", @prev_page, :method => :get %>
		</td>
	</tr>
</table>

<script language="JavaScript">
	function inhousetoggle()
	{
		var companyTb = document.getElementById('contact_company');
		var inhouseCb = document.getElementById('contact_inhouse');
		
		if (inhouseCb.checked) 
			companyTb.value = "Inhouse Personnel";
		else
			companyTb.value = "";
		
		companyTb.disabled = inhouseCb.checked;
	}
</script>

